Skip to content

feat(dev): fix dot-worktree resolution, unique task files, and --agent/-a UX#458

Merged
basnijholt merged 4 commits intomainfrom
agent-flag
Mar 23, 2026
Merged

feat(dev): fix dot-worktree resolution, unique task files, and --agent/-a UX#458
basnijholt merged 4 commits intomainfrom
agent-flag

Conversation

@basnijholt
Copy link
Copy Markdown
Owner

@basnijholt basnijholt commented Mar 23, 2026

Summary

  • allow dev agent . and other dev commands to resolve the current worktree via find_worktree_by_name
  • write prompts to unique .claude/TASK-{timestamp}-{hex}.md files to avoid parallel-launch collisions
  • use mkstemp for unique prompt wrapper scripts
  • make --agent/-a the primary selector for dev agent, while keeping --with-agent as a deprecated alias
  • update help text, docs, and skill guidance to match the new behavior

Testing

  • uv run pytest tests/dev/test_cli.py tests/dev/test_launch.py tests/dev/test_worktree.py

@basnijholt basnijholt changed the title feat(dev): fix usability bugs - dot worktree, unique task files, --ag… feat(dev): fix dot-worktree resolution, unique task files, and --agent/-a UX Mar 23, 2026
Copy link
Copy Markdown
Owner Author

@basnijholt basnijholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BUG] . resolves to the main checkout for nested worktrees

_find_worktree_for_cwd() currently returns the first worktree whose path prefixes the current directory. git worktree list reports the main checkout first, so when a worktree lives under the repo root (for example .worktrees/feature), the main repo matches before the nested worktree does.

That makes the new . behavior target the wrong checkout for the exact dot-worktree layout called out in this PR: dev agent ., dev path ., dev editor ., and dev rm . will all resolve to the main repo instead of the nested worktree.

Minimal repro:

  • main repo: /repo
  • worktree: /repo/.worktrees/feature
  • cwd: /repo/.worktrees/feature/src
  • current result: /repo
  • expected result: /repo/.worktrees/feature

Please pick the most specific matching worktree path instead of the first match, and add a regression test that uses a nested .worktrees/... layout.

[MINOR] docs/commands/dev.md still describes the old task-file behavior

The paragraph at docs/commands/dev.md:748 still says .claude/TASK.md reflects the most recent launch. After this patch each launch writes a unique TASK-{timestamp}-{hex}.md, so that note is now stale.

…ent/-a primary

- dev agent . resolves to current worktree via find_worktree_by_name
- write_prompt_to_worktree uses unique TASK-{ts}-{hex}.md filenames
- _create_prompt_wrapper_script uses mkstemp for unique script paths
- dev agent: --agent/-a is primary flag, --with-agent deprecated alias
- Updated help text, docs, skill documentation
- 7 new tests covering all fixes + race condition regression
@basnijholt basnijholt merged commit ee894c9 into main Mar 23, 2026
1 check passed
@basnijholt basnijholt deleted the agent-flag branch March 23, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant